package com.javatest2;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @program: item_02
 * @description: 给定一个字符串s由小写字符组成，移除多余的字符使得每个字符只出现一次。
 * 你必须保证结果是字典序是最小的合法字符串。
 * <p>
 * 输入: s = "bcabc"
 * 输出: "abc"
 * <p>
 * 输入: s = "cbacdcbc"
 * 输出: "acdb"
 * @author: LL
 * @create: 2021-02-09 10:33
 */
public class Subject17 {

    public static void test2(final String a) {
        final char[] chars = a.toCharArray();
        String str = "";
        for (final char aChar : chars) {
            str = str + aChar + ",";
        }
        final List<String> b = new ArrayList<String>();
        final String[] split = str.split(",");
        final List<String> list = Arrays.asList(split);
        for (final String s : list) {
            if (!b.contains(s)) {
                b.add(s);
            }
        }
        System.out.println(b);
    }

    public static void main(final String[] args) {
        final String a = "aeeffa56565dhhfh506threadodvo05605fohsxdvdi";
        test2(a);
    }

}
